package ar.edu.utn.frgp.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.edu.utn.frgp.model.Paquete;
import ar.edu.utn.frgp.servicio.PaqueteService;

public class PaquetesServlet extends GenericServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private PaqueteService paqService;
	
	public PaquetesServlet(){
		super();
		paqService = new PaqueteService();
		
	} 
	
	@Override
	public void doAction(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		try {
			List<Paquete> paquetes = paqService.getPaquetes();
			request.setAttribute("paquetes", paquetes);
			request.getSession().setAttribute("paquetesNombres", paquetes);
			request.getRequestDispatcher("/paquetes.jsp").forward(request, response);
			
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}	
}
